home *** CD-ROM | disk | FTP | other *** search
- #include <string.h>
- #include <Events.h>
- #include <Resources.h>
- #include <Memory.h>
- #include <ToolUtils.h>
- #include <SysEqu.h>
- #include <Notification.h>
-
- #include "notif.h"
- #include "sortWindow.h"
-
-
- #define SICN_ID 128
- #define NM_STRS 128
-
- #define SEND_AGAIN_TIME 5L*60L*60L
-
- static pascal void nmResponce(NMRecPtr notif);
-
- Boolean gInBackground;
-
- void send_Message(short id)
- {
- Str255 notiftext;
- NMRec notif;
- long len1, len2;
- NMProcPtr responseProcPtr = (NMProcPtr)nmResponce;
-
-
- notif.qType = nmType;
- notif.nmMark = 0;
- notif.nmIcon = GetResource('SICN', SICN_ID);
- HLock(notif.nmIcon);
- HNoPurge(notif.nmIcon);
-
- notif.nmSound = (Handle)-1;
-
- notif.nmStr = notiftext;
- notif.nmResp = responseProcPtr;
- notif.nmRefCon = 0L;
-
- GetIndString(notiftext, NM_STRS, id);
- len1 = *notiftext;
- len2 = *(Ptr)CurApName;
- if ((len1 + len2) > 255) {
- len1 = 255-len2;
- }
- BlockMove(notiftext, notiftext + len2, len1 + 1);
- BlockMove((Ptr)CurApName, notiftext, len2 + 1);
- *notiftext = (len1 + len2) & 0xFF;
-
-
- NMInstall(¬if);
-
- do {
- HandleEvent();
- } while (notif.nmRefCon == 0L);
- HandleEvent();
- HandleEvent();
- HandleEvent();
- }
-
- static pascal void nmResponce(NMRecPtr notif)
- {
- notif->nmRefCon = TickCount();
- NMRemove(notif);
- }
-
-
- void wait_Foreground(short id)
- {
- Str255 notiftext;
- NMRec notif;
- long len1, len2;
- NMProcPtr responseProcPtr = (NMProcPtr)nmResponce;
-
- notif.qType = nmType;
- notif.nmMark = 1;
- notif.nmIcon = GetResource('SICN', SICN_ID);
- HLock(notif.nmIcon);
- HNoPurge(notif.nmIcon);
-
- notif.nmSound = (Handle)-1;
- notif.nmStr = notiftext;
- notif.nmResp = responseProcPtr;
- notif.nmRefCon = 0L;
-
- GetIndString(notiftext,NM_STRS, id);
- len1 = *notiftext;
- len2 = *(Ptr)CurApName;
- if ((len1 + len2) > 255) {
- len1 = 255-len2;
- }
- BlockMove(notiftext, notiftext + len2, len1 + 1);
- BlockMove((Ptr)CurApName, notiftext, len2 + 1);
- *notiftext = (len1 + len2) & 0xFF;
- NMInstall(¬if);
-
- do {
- HandleEvent();
- if ((notif.nmRefCon != 0) &&
- ((TickCount() - notif.nmRefCon)>SEND_AGAIN_TIME)) {
- notif.nmSound = (Handle)-1;
- notif.nmStr = notiftext;
- notif.nmResp = responseProcPtr;
- notif.nmRefCon = 0L;
- NMInstall(¬if);
- }
- } while (gInBackground);
-
- HandleEvent();
- HandleEvent();
- HandleEvent();
- }
-